home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_INT.ZIP / SPX_DMA.INT < prev    next >
Text File  |  1993-09-15  |  3KB  |  79 lines

  1. Unit spx_dma;
  2.  
  3. {$O+,X+,S- }
  4. { SPX Library Version 2.0  Copyright 1993 Scott D. Ramsay }
  5. { sprite data.  Requires Turbo Vision unit: MEMORY }
  6.  
  7. { Digital sound for Sound Blaster and compatibles via DMA }
  8. { Only supports mono wav and voc files. :(                }
  9.  
  10. Interface
  11.  
  12. Uses crt,dos,spx_dos,spx_fnc,memory;
  13.  
  14. const
  15.   DEFAULT_BUFFER : word = $2000;
  16.   DEFAULT_IRQ    : byte = 5;
  17.   DEFAULT_DMA    : byte = 1;
  18.   spxDMAnoerror  = 0;
  19.   spxDMAnoSB     = -1;         { unable to init sound blaster card }
  20.   spxDMAnomem    = -2;         { unable to allocate DMA buffers }
  21.   spxDMAplaying  = -3;         { sound still playing }
  22.   spxDMAcomplete = -4;         { sound is complete }
  23.   spxDMAdiskerr  = -5;         { error reading sound file }
  24.   spxDMAnotinit  = -6;         { PdigiInfo not initalized }
  25.  
  26. type
  27.   PdigiInfo = ^TdigiInfo;
  28.   TdigiInfo = record
  29.                 hz,                  { sample rate }
  30.                 fhandle  : word;     { dos file handle }
  31.                 spoint,              { start point in file }
  32.                 fsize    : longint;  { sample size in file }
  33.                 inmem    : pointer;  { use if fhandle = 0 }
  34.                 fln      : string;   { audio file name }
  35.                 dspoint  : longint;  { internal use do not modify }
  36.                 tsize    : word;     { internal use do not modify }
  37.                 playmode : byte;     { internal use do not modify }
  38.               end;
  39.   PWAVHDR   = ^TWAVHDR;
  40.   TWAVHDR   = record
  41.                 riff    : array[0..3] of char;  { "RIFF" }
  42.                 fln1    : longint;              { filesize-8 }
  43.                 WaveFmt : array[0..7] of char;  { "WAVEfmt"#32 }
  44.                 NoClue  : array[0..7] of byte;  { I have no idea }
  45.                 Sampl1,                         { Sample rates }
  46.                 Sampl2  : longint;              {  in Hz }
  47.                 NoClue2 : longint;              { I have no idea 2 }
  48.                 data    : array[0..3] of char;  { "data" }
  49.                 fln2    : longint;              { filesize-44 }
  50.               end;
  51.   PVOCHDR   = ^TVOCHDR;
  52.   TVOCHDR   = record
  53.                 ftypedes : array[0..$13] of char;
  54.                 doff,ver,
  55.                 id       : word;
  56.               end;
  57.   INT3      = array[0..2] of byte;
  58.   PVOCDHDR  = ^TVOCDHDR;
  59.   TVOCDHDR  = record
  60.                 kind   : byte; { 1 = Voice Data }
  61.                 blklen : INT3;
  62.                 tc     : byte; { time constant }
  63.                 pack   : byte; { compression: 0 = 8-bit raw }
  64.               end;
  65.  
  66. var
  67.   irq,dma    : byte;
  68.   base,
  69.   BufferSize : word;
  70.   InitError  : integer;
  71.  
  72. function open_wav(filename:string):PdigiInfo; { open wav for reading }
  73. function open_voc(filename:string):PdigiInfo; { open voc for reading }
  74. function load_wav(filename:string):PdigiInfo; { load 64k or smaller wav in mem }
  75. function load_voc(filename:string):PdigiInfo; { load 64k or smaller voc in mem }
  76. function play_digi(p:PdigiInfo;rstart:boolean):integer;  { play PdigiInfo }
  77. procedure cleanup_digi(var p:PdigiInfo);      { remove from mem/close file }
  78.  
  79.